<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;

class SetMpMenu extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'csw:SetMpMenu';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * @var
     */
    protected $app;

    /**
     * Create a new command instance.
     *
     */
    public function __construct()
    {
        parent::__construct();
        $this->app = app('wechat.official_account');
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $this->info("csw:SetMpMenu start!");

        $buttons = [
            [
                "type" => "view",
                "name" => "今日OTT",
                "url"  => "http://ott.gz-data.com"
            ],
            [
                "name"       => "收视报",
                "sub_button" => [
                    [
                        "type" => "view",
                        "name" => "收视报",
                        "url"  => "https://mp.weixin.qq.com/mp/homepage?__biz=MzI5NjA1MzEyOA==&hid=3&sn=d8d78255c603530338706ba8d76d6bfe&scene=18#wechat_redirect"
                    ],
                    [
                        "type" => "view",
                        "name" => "TV馆儿",
                        "url"  => "https://mp.weixin.qq.com/mp/homepage?__biz=MzI5NjA1MzEyOA==&hid=1&sn=8806c61b20b3dfb49c2823ebe1e654ff&scene=18#wechat_redirect"
                    ]
                ],
            ],
            [
                "name"       => "勾正菌",
                "sub_button" => [
                    [
                        "type" => "view",
                        "name" => "讲个故事",
                        "url"  => "https://mp.weixin.qq.com/mp/homepage?__biz=MzI5NjA1MzEyOA==&hid=2&sn=280c8e89509527762ec3138775782b6d&scene=18#wechat_redirect"
                    ],
                    [
                        "type" => "click",
                        "name" => "撩个私信",
                        "key"  => "MenuClick_Liao001"
                    ],
                    [
                        "type" => "view",
                        "name" => "勾正官网",
                        "url"  => "http://www.gz-data.com"
                    ]
                ],
            ]
        ];
        //$this->app->menu->delete();
        $result = $this->app->menu->create($buttons);
        var_dump($result);
        $this->info("csw:SetMpMenu end!");
    }
}
